// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sys

import (
	"context"
	"hotgo/api/admin/productcategory"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	ProductCategory = cProductCategory{}
)

type cProductCategory struct{}

// List 查看商品分类列表
func (c *cProductCategory) List(ctx context.Context, req *productcategory.ListReq) (res *productcategory.ListRes, err error) {
	list, totalCount, err := service.SysProductCategory().List(ctx, &req.ProductCategoryListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.ProductCategoryListModel{}
	}

	res = new(productcategory.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Edit 更新商品分类
func (c *cProductCategory) Edit(ctx context.Context, req *productcategory.EditReq) (res *productcategory.EditRes, err error) {
	err = service.SysProductCategory().Edit(ctx, &req.ProductCategoryEditInp)
	return
}

// MaxSort 获取商品分类最大排序
func (c *cProductCategory) MaxSort(ctx context.Context, req *productcategory.MaxSortReq) (res *productcategory.MaxSortRes, err error) {
	data, err := service.SysProductCategory().MaxSort(ctx, &req.ProductCategoryMaxSortInp)
	if err != nil {
		return
	}

	res = new(productcategory.MaxSortRes)
	res.ProductCategoryMaxSortModel = data
	return
}

// View 获取指定商品分类信息
func (c *cProductCategory) View(ctx context.Context, req *productcategory.ViewReq) (res *productcategory.ViewRes, err error) {
	data, err := service.SysProductCategory().View(ctx, &req.ProductCategoryViewInp)
	if err != nil {
		return
	}

	res = new(productcategory.ViewRes)
	res.ProductCategoryViewModel = data
	return
}

// Delete 删除商品分类
func (c *cProductCategory) Delete(ctx context.Context, req *productcategory.DeleteReq) (res *productcategory.DeleteRes, err error) {
	err = service.SysProductCategory().Delete(ctx, &req.ProductCategoryDeleteInp)
	return
}

// Status 更新商品分类状态
func (c *cProductCategory) Status(ctx context.Context, req *productcategory.StatusReq) (res *productcategory.StatusRes, err error) {
	err = service.SysProductCategory().Status(ctx, &req.ProductCategoryStatusInp)
	return
}


